﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Security.Cryptography;
using RestSharp;
using Newtonsoft.Json;
using System.Text;
using Newtonsoft.Json.Linq;
using System.Windows;
using CefSharp;
using Microsoft.Win32;

public class WebBrowserDownloadHandler : IDownloadHandler
{
    public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
    {
        if (!callback.IsDisposed)
        {
            using (callback)
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.FileName = "数据分析.xlsx";
                if(dialog.ShowDialog().Value==true)
                {
                    callback.Continue(dialog.FileName,
                    showDialog: true);
                }
            }
        }
    }

    public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
    {
        
    }
}